package com.lwt.service.impl;

import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.lwt.dao.HouseMapper;
import com.lwt.model.District;
import com.lwt.model.House;
import com.lwt.model.Street;
import com.lwt.model.Types;
import com.lwt.service.HouseService;
import com.lwt.util.Page;

@Service("houseservice")
public class HouseServiceImpl implements HouseService {
	@Autowired
	private HouseMapper dao;
	
	public boolean addHouse(House house) {
		// TODO Auto-generated method stub
		return dao.addHouse(house);
	}

	public boolean deleteHouse(House house) {
		// TODO Auto-generated method stub
		return dao.deleteHouse(house);
	}

	public List<District> showAllDistrict() {
		// TODO Auto-generated method stub
		return dao.getAllDistrict();
	}

	public List<Types> showAllTypes() {
		// TODO Auto-generated method stub
		return dao.getAllTypes();
	}

	public Map<String ,Object> showHouseById(House house) {
		// TODO Auto-generated method stub
		return dao.getHouseById(house);
	}

	public boolean updateHouse(House house) {
		// TODO Auto-generated method stub
		return dao.updateHouse(house);
	}

	public Page getLikeHouse(Map<String, Object> houseinfo) {
		Page page=new Page();
		page.setTotalNum(dao.getLikeHouseCount(houseinfo));
		int pageSize = Integer.parseInt(String.valueOf(houseinfo.get("pageSize")));
		page.setPageSize(pageSize);
		int curPageNum = Integer.parseInt(String.valueOf(houseinfo.get("pageNum")));
		page.setCurPageNum(curPageNum);
		page.setTotalPage(page.getTotalNum()/pageSize+(page.getTotalNum()%pageSize==0?0:1));
		page.setResult(dao.getLikeHouse(houseinfo));
		return page;
	}

	public List<Street> showAllStreetByDid(Street street) {
		// TODO Auto-generated method stub
		return dao.getAllStreetByDid(street);
	}



}
